package cn.edu.hbwe.book.servlet.Notice;

import java.io.IOException;


import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import cn.edu.hbwe.book.entity.Notice;
//import cn.edu.hbwe.book.entity.NoticeService;
import cn.edu.hbwe.book.service.notice.NoticeService;

/**
 *	后台查询所有公告的servlet
 */
@WebServlet("/ListNoticeServlet")
public class ListNoticeServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException  {
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		NoticeService nd=new NoticeService();
		nd.findAll();
		List<Notice> notices = nd.findAll();
		request.setAttribute("notices", notices);
		
		request.getRequestDispatcher("admin/notices/list.jsp").forward(request, response);
	}
}
